package com.taxicall.client;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Confirmation extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_confirmation);
	}
	
	protected void onResume() {
		super.onResume();
		Bundle extras = getIntent().getExtras();
		String destination = extras.getString("slName");
		boolean foundTaxi = extras.getBoolean("foundTaxi");
		
		if(foundTaxi) {
			TextView tv1 = (TextView) findViewById(R.id.confirmation);
			TextView tv2 = (TextView) findViewById(R.id.thanks);
			tv1.setText("A taxi will pick you up from "+destination+" in a few minutes.");
			tv2.setText("Thank you for using Taxicall!");
			
			Button button = (Button) findViewById(R.id.button1);
			button.setText("Exit");
			
			button.setOnClickListener(new View.OnClickListener() {
				
				public void onClick(View v) {
					System.exit(0);
				}				
			});
		}
		else {
			TextView tv2 = (TextView) findViewById(R.id.thanks);
			tv2.setText("We are sorry, but there aren't any available taxis near you.\nPlease try again later.");
			
			Button button = (Button) findViewById(R.id.button1);
			button.setText("Try again");
			
			button.setOnClickListener(new View.OnClickListener() {
				
				public void onClick(View v) {
					Intent intent = new Intent(getApplicationContext(), StartPointSelection.class);
					intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
					startActivity(intent);
				}				
			});
		}
	}
}
